import datetime

from django.utils.translation import ugettext as _
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

from django_community.managers import UserOpenIDManager, UserProfileManager

class UserProfile(models.Model):
    ip_address = models.IPAddressField(_('ip'), blank = True, null = True)
    is_anonymous = models.BooleanField(_('anonymous'), default = False)
    
    website = models.URLField(_('website'), max_length = 200,  blank = True)
    birthdate = models.DateField(_('birthday'), blank = True,  null = True)
    location = models.CharField(_('location'), max_length = 200,  blank = True)
    display_name = models.CharField(_('display name'), max_length = 100,  blank = True)
    about_me = models.TextField(_('about'), default = '',  blank = True)
    
    user = models.ForeignKey(User, unique = True, related_name = 'profile')
    
    objects = UserProfileManager()
    
    def __unicode__(self):
        return self.user.username

class UserOpenID(models.Model):
    openid = models.TextField()
    date_created = models.DateTimeField(auto_now_add = True, auto_now = False)
    user = models.ForeignKey(User, related_name = 'openids')
    
    objects = UserOpenIDManager()